﻿using System;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

namespace DatabaseGroup.UnitTests.SSIS.SourceAdapters
{
    /// <summary>
    /// Implements dummy IDTSOutputColumn100 functionality to aid testing
    /// </summary>
    public class OutputColumnTestImpl : IDTSOutputColumn100
    {
        private int _id = 0;
        private string _name = string.Empty;
        private string _description = string.Empty;
        private DataType _dataType;
        private int _length = 0;

        private DTSRowDisposition _errorRowDisposition = DTSRowDisposition.RD_FailComponent;
        private DTSRowDisposition _truncationRowDisposition = DTSRowDisposition.RD_FailComponent;

        private CustomPropertyCollectionTestImpl _customPropertyCollection = new CustomPropertyCollectionTestImpl();

        #region IDTSOutputColumn100 Members

        public int ID
        {
            get { return _id; }
            set { _id = value; }
        }

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        public string IdentificationString
        {
            get { return string.Format("output \"{0}\" ({1})", this.Name, this.ID); }
        }

        public int CodePage
        {
            get { throw new NotImplementedException(); }
        }

        public int ComparisonFlags
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public IDTSCustomPropertyCollection100 CustomPropertyCollection
        {
            get { return _customPropertyCollection; }
        }

        public DataType DataType
        {
            get { return _dataType; }
        }

        public string ErrorOrTruncationOperation
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public DTSRowDisposition ErrorRowDisposition
        {
            get
            {
                return _errorRowDisposition;
            }
            set
            {
                _errorRowDisposition = value;
            }
        }

        public DTSRowDisposition TruncationRowDisposition
        {
            get
            {
                return _truncationRowDisposition;
            }
            set
            {
                _truncationRowDisposition = value;
            }
        }

        public int ExternalMetadataColumnID
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public int Length
        {
            get { return _length; }
        }

        public int LineageID
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public int MappedColumnID
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public DTSObjectType ObjectType
        {
            get { return DTSObjectType.OT_OUTPUTCOLUMN; }
        }

        public int Precision
        {
            get { throw new NotImplementedException(); }
        }

        public int Scale
        {
            get { throw new NotImplementedException(); }
        }

        public void SetDataTypeProperties(DataType eDataType, int lLength, int lPrecision, int lScale, int lCodePage)
        {
            _dataType = eDataType;
            _length = lLength;
        }

        public int SortKeyPosition
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public int SpecialFlags
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion
    }
}
